// Java 객체를 JS 객체로 변환
function forJS(oObject) {

	// HashMap -> Object
	if (oObject instanceof java.util.HashMap) {

		var oDatas = {};
		var aKeys = oObject['keySet']().toArray();

		for (var nIndex in aKeys) {

			var sKey = aKeys[nIndex];
			var sVal = oObject.get(sKey);

			oDatas[sKey] = forJS(sVal);

		}

		return oDatas;

	// ArrayList -> Array
	} else if (oObject instanceof java.util.ArrayList) {

		var aDatas = [];

		for (var i = 0, len = oObject.size(); i < len; i++)
			aDatas.push(forJS(oObject.get(i)));

		return aDatas;

	// Double/Float/Integer -> Number
	} else if (oObject instanceof java.lang.Double || oObject instanceof java.lang.Float || oObject instanceof java.lang.Integer) {

		return parseFloat(oObject);

	// String -> String
	} else if (oObject instanceof java.lang.String) {

		return String(oObject);

	}

	return oObject;

}

// JS 객체를 Java 객체로 변환
function forJava(oObject) {

	// Array -> ArrayList
	if (oObject.constructor === Array) {

		var oArray = new java.util.ArrayList();

		for (var i = 0, len = oObject.length; i < len; i++)
			oArray.add(forJava(oObject[i]));

		return oArray;

	// Object -> HashMap
	} else if (oObject.constructor === Object) {

		var oHash = new java.util.HashMap();

		for (var sKey in oObject)
			oHash.put(sKey, forJava(oObject[sKey]));

		return oHash;

	}

	return oObject;

}

function sayHello() {
    var message = 'Hello, ' + name;
    return message;
}

function sayGoodbye() {
    var oList = $A(forJS(param));
	var nRet = 'Goodbye, ';

	oList.forEach(function(v) {
		nRet += v;
	});

	return forJava(nRet);  
}

/**
 * Core object
 *
 */
/*
if (typeof window.nhn == "undefined") {
	window.nhn = new Object;
}
*/

/*
function $(sID) {
	var ret = new Array;
	var el  = null;
	var reg = /<([a-z]+|h[1-5])>/i;

	for(var i=0; i < arguments.length; i++) {
		el = arguments[i];
		if (typeof el == "string") {
			if (reg.test(el)) {
				el = document.createElement(RegExp.$1);
			} else {
				el = document.getElementById(el);
			}
		}
		if (el) ret[ret.length] = el;
	}
	return ret.length?((arguments.length>1)?ret:ret[0]):null;
}
*/

function $Class(oDef) {
	function typeClass() {
		var t = this;

		while(typeof t.$super != "undefined") {
			t.$super.$this = this;
			if (typeof t.$super.$init != "undefined") t.$super.$init.apply(t.$super,arguments);
			t = t.$super;
		}

		if (typeof this.$init != "undefined") this.$init.apply(this,arguments);
	};

	typeClass.prototype = oDef;
	typeClass.prototype.constructor = typeClass;
	typeClass.extend = $Class.extend;

	return typeClass;
 }

 $Class.extend = function(superClass) {
	this.prototype.$super = new Object;

	var superFunc = function(m, func) {
		return function() {
			var r;
			var f = this.$this[m];
			var t = this.$this;
			t[m] = func;
			r = t[m].apply(t, arguments);
			t[m] = f;

			return r;
		}
	};

	for(var x in superClass.prototype) {
		if (typeof this.prototype[x] == "undefined" && x !="$init") this.prototype[x] = superClass.prototype[x];
		if (typeof superClass.prototype[x] == "function") {
			this.prototype.$super[x] = superFunc(x, superClass.prototype[x]);
		} else {
			this.prototype.$super[x] = superClass.prototype[x];
		}

	}

	// inherit static methods of parent
	for(var x in superClass) {
		if (x == "prototype") continue;
		this[x] = superClass[x];
	}

	return this;
};

function $A(array) {
	var cl = arguments.callee;

	if (typeof array == "undefined") array = [];
	if (array instanceof cl) return array;
	if (!(this instanceof cl)) return new cl(array);

	this._array = [];
	for(var i=0; i < array.length; i++) {
		this._array[this._array.length] = array[i];
	}
};

$A.prototype.toString = function() {
	return this._array.toString();
};

$A.prototype.length = function(len, elem) {
	if (typeof len == "number") {
		var l = this._array.length;
		this._array.length = len;

		if (typeof elem != "undefined") {
			for(var i=l; i < len; i++) {
				this._array[i] = elem;
			}
		}

		return this;
	} else {
		return this._array.length;
	}
};

$A.prototype.has = function(any) {
	return (this.indexOf(any) > -1);
};

$A.prototype.indexOf = function(any) {
	if (typeof this._array.indexOf != 'undefined') return this._array.indexOf(any);

	for(var i=0; i < this._array.length; i++) {
		if (this._array[i] == any) return i;
	}
	return -1;
};

/*
 * JavaScript �迭 ��ü�� ��ȯ�Ѵ�
 * @id core.$A.$value
 * @return {Array} JavaScript �迭 ��ü
 */
$A.prototype.$value = function() {
	return this._array;
};

$A.prototype.push = function(element1/*, ...*/) {
	return this._array.push.apply(this._array, $A(arguments).$value());
};

$A.prototype.pop = function() {
	return this._array.pop();
};

$A.prototype.shift = function() {
	return this._array.shift();
};

$A.prototype.unshift = function(element1/*, ...*/) {
	this._array.unshift.apply(this._array, $A(arguments).$value());

	return this._array.length;
};

$A.prototype.forEach = function(callback, thisObject) {
	if (typeof this._array.forEach == "function") {
		this._array.forEach.apply(this._array, arguments);
		return this;
	}

	for(var i=0; i < this._array.length; i++) {
		try {
			callback.call(thisObject, this._array[i], i, this._array);
		} catch(e) {
			if (e instanceof $A.Break) break;
			if (e instanceof $A.Continue) continue;
		}
	}

	return this;
};

$A.prototype.map = function(callback, thisObject) {
	if (typeof this._array.map == "function") {
		this._array = this._array.map.apply(this._array, arguments);
		return this;
	}

	for(var i=0; i < this._array.length; i++) {
		try {
			this._array[i] = callback.call(thisObject, this._array[i], i, this._array);
		} catch(e) {
			if (e instanceof $A.Break) break;
			if (e instanceof $A.Continue) continue;
		}
	}

	return this;
};

$A.prototype.filter = function(callback, thisObject) {
	var ar = new Array;

	this.forEach(function(v,i,a) {
		if (callback.call(thisObject, v, i, a) === true) {
			ar[ar.length] = v;
		}
	});

	return $A(ar);
};

$A.prototype.every = function(callback, thisObject) {
	if (typeof this._array.every != "undefined") return this._array.every(callback, thisObject);

	var result = true;
	this.forEach(function(v, i, a) {
		if (callback.call(thisObject, v, i, a) === false) {
			result = false;
			$A.Break();
		}
	});
	return result;
};

$A.prototype.some = function(callback, thisObject) {
	if (typeof this._array.some != "undefined") return this._array.some(callback, thisObject);

	var result = false;
	this.forEach(function(v, i, a) {
		if (callback.call(thisObject, v, i, a) === true) {
			result = true;
			$A.Break();
		}
	});
	return result;
};

$A.prototype.refuse = function(value) {
	var a = $A(arguments);
	return this.filter(function(v,i) { return !a.has(v) });
};

$A.prototype.slice = function(start, end) {
	var a = this._array.slice.call(this._array, start, end);
	return $A(a);
};

$A.prototype.splice = function(index, howMany/*, element*/) {
	var a = this._array.splice.apply(this._array, arguments);

	return $A(a);
};

$A.prototype.suffle = function() {
	this._array.sort(function(a,b){ return Math.random()>Math.random()?1:-1 });

	return this;
};

$A.prototype.unique = function() {
	var a = this._array, b = [], l = a.length;
	var i, j;

	for(i = 0; i < l; i++) {
		for(j = 0; j < b.length; j++) {
			if (a[i] == b[j]) break;
		}

		if (j >= b.length) b[j] = a[i];
	}

	this._array = b;

	return this;
};

$A.Break = function() {
	if (window === $A) throw new $A.Break;
};

$A.Continue = function() {
	if (window === $A) throw new $A.Continue;
};

function $H(hashObject) {
	var cl = arguments.callee;
	if (typeof hashObject == "undefined") hashObject = new Object;
	if (hashObject instanceof cl) return hashObject;
	if (!(this instanceof cl)) return new cl(hashObject);

	this._table = {};
	for(var k in hashObject) {
		if (this._table[k] == hashObject[k]) continue;
		this._table[k] = hashObject[k];
	}
}

$H.prototype.$value = function() {
	return this._table;
}

$H.prototype.length = function() {
	var i = 0;
	for(var k in this._table) {
		if (typeof Object.prototype[k] != "undeifned" && Object.prototype[k] === this._table[k]) continue;
		i++;
	}

	return i;
}

$H.prototype.forEach = function(callback, thisObject) {
	for(var k in this._table) {
		if (typeof Object.prototype[k] != "undeifned" && Object.prototype[k] === this._table[k]) continue;
		try {
			callback.call(thisObject, this._table[k], k, this._table);
		} catch(e) {
			if (e instanceof $H.Break) break;
			if (e instanceof $H.Continue) continue;
		}
	}
	return this;
}

$H.prototype.filter = function(callback, thisObject) {
	var h = $H();
	this.forEach(function(v,k,o) {
		if(callback.call(thisObject, v, k, o) === true) {
			h.add(k,v);
		}
	});
	return h;
}

$H.prototype.map = function(callback, thisObject) {
	var t = this._table;
	this.forEach(function(v,k,o) {
		t[k] = callback.call(thisObject, v, k, o);
	});
	return this;
}

$H.prototype.add = function(key, value) {
	this._table[key] = value;
	return this._table[key];
}

$H.prototype.remove = function(key) {
	if (typeof this._table[key] == "undefined") return null;
	var val = this._table[key];
	delete this._table[key];

	return val;
}

$H.prototype.search = function(value) {
	var result = false;
	this.forEach(function(v,k,o) {
		if (v === value) {
			result = k;
			$H.Break();
		}
	});
	return result;
}

$H.prototype.hasKey = function(key) {
	var result = false;

	return (typeof this._table[key] != "undefined");
}

$H.prototype.hasValue = function(value) {
	return (this.search(value) !== false);
}

$H.prototype.sort = function() {
	var o = new Object;
	var a = this.values();
	var k = false;

	a.sort();

	for(var i=0; i < a.length; i++) {
		k = this.search(a[i]);

		o[k] = a[i];
		delete this._table[k];
	}

	this._table = o;

	return this;
}

$H.prototype.ksort = function() {
	var o = new Object;
	var a = this.keys();

	a.sort();

	for(var i=0; i < a.length; i++) {
		o[a[i]] = this._table[a[i]];
	}

	this._table = o;

	return this;
}

$H.prototype.keys = function() {
	var keys = new Array;
	for(var k in this._table) {
		keys.push(k);
	}

	return keys;
}

$H.prototype.values = function() {
	var values = new Array;
	for(var k in this._table) {
		values.push(this._table[k]);
	}

	return values;
}

$H.Break = function() {
	if (this === $H) throw new $H.Break;
}

$H.Continue = function() {
	if (this === $H) throw new $H.Continue;
}

function $Fn(func, thisObject) {
	var cl = arguments.callee;
	if (func instanceof cl) return func;
	if (!(this instanceof cl)) return new cl(func, thisObject);

	this._events = [];
	this._tmpElm = null;

	if (typeof func == "function") {
		this._func = func;
		this._this = thisObject;
	} else if (typeof func == "string" && typeof thisObject == "string") {
		this._func = new Function(func, thisObject);
	}
}

$Fn.prototype.$value = function() {
	return this._func;
}

$Fn.prototype.bind = function() {
	var a = $A(arguments).$value();
	var f = this._func;
	var t = this._this;

	var b = function() {
		var args = $A(arguments).$value();

		// fix opera concat bug
		if (a.length) args = a.concat(args);

		return f.apply(t, args);
	};

	return b;
}

/**
 *
 * @id core.$Fn.bindForEvent
 * @import core.$A
 * @import core.$Event
 */
/*
$Fn.prototype.bindForEvent = function() {
	var a = arguments;
	var f = this._func;
	var t = this._this;
	var m = this._tmpElm || null;

	var b = function(e) {
		var args = $A(a);
		if (typeof e == "undefined") e = window.event;

		if (typeof e.currentTarget == "undefined") {
			e.currentTarget = m;
		}

		args.unshift($Event(e));

		return f.apply(t, args.$value());
	};

	return b;
}
*/

/*
$Fn.prototype.attach = function(oElement, sEvent) {
	var f;

	if ((oElement instanceof Array) || ($A && (oElement instanceof $A) && (oElement=oElement.$value()))) {
		for(var i=0; i < oElement.length; i++) {
			this.attach(oElement[i], sEvent);
		}
		return this;
	}

	if ($Element && oElement instanceof $Element) {
		oElement = oElement.$value();
	}

	oElement = $(oElement);
	sEvent   = sEvent.toLowerCase();

	this._tmpElm = oElement;
	f = this.bindForEvent();
	this._tmpElm = null;

	if (typeof oElement.attachEvent != "undefined") {
		oElement.attachEvent("on"+sEvent, f);
	} else {
		if (sEvent == "mousewheel") sEvent = "DOMMouseScroll";


		if (sEvent == "DOMMouseScroll" && navigator.userAgent.indexOf("WebKit") > 0) {
			var events = "__jindo_wheel_events";

			if (typeof oElement[events] == "undefined") oElement[events] = new Array;
			if (typeof oElement.onmousewheel == "object") {
				oElement.onmousewheel = function(evt) {
					if (!this[events]) return;
					for(var i=0; i < this[events].length; i++) {
						this[events][i](evt);
					}
				}
			}

			oElement[events][oElement[events].length] = f;
		} else {
			oElement.addEventListener(sEvent, f, false);
		}
	}

	this._events[this._events.length] = {element:oElement, event:sEvent, func:f};
	$Fn.gc.pool.push({element:oElement, event:sEvent, func:f});

	return this;
}
*/

/*
$Fn.prototype.detach = function(oElement, sEvent) {
	if ((oElement instanceof Array) || ($A && (oElement instanceof $A) && (oElement=oElement.$value()))) {
		for(var i=0; i < oElement.length; i++) {
			this.detach(oElement[i], sEvent);
		}
		return this;
	}

	if ($Element && oElement instanceof $Element) {
		oElement = oElement.$value();
	}

	oElement = $(oElement);
	sEvent   = sEvent.toLowerCase();

	var e = this._events;
	var l = this._events.length;
	var f = null;

	for(var i=0; i < l; i++) {
		if (e[i].element !== oElement || e[i].event !== sEvent) continue;
		f = e[i].func;
		for(var j=i; j < l-1; j++) {
			this._events[j] = this._events[j+1];
		}
		break;
	}

	if (this._events.length) this._events.length--;

	if (typeof oElement.detachEvent != "undefined") {
		oElement.detachEvent("on"+sEvent, f);
	} else {
		if (sEvent.toLowerCase() == "mousewheel") sEvent = "DOMMouseScroll";

		if (sEvent == "DOMMouseScroll" && navigator.userAgent.indexOf("WebKit") > 0) {
			var events = "__jindo_wheel_events", found = false;
			if (!oElement[events]) return;
			for(var i=0; i < oElement[events].length; i++) {
				if (oElement[events][i] == f) {
					found = true;
				} else if (found) {
					oElement[events][i-1] = oElement[events][i];
				}
			}
			if (oElement[events].length) oElement[events].length--;
		} else {
			oElement.removeEventListener(sEvent, f, false);
		}
	}

	return this;
}
*/

/*
$Fn.gc = function() {
	var p = $Fn.gc.pool;
	var l = $Fn.gc.pool.length;
	for(var i=0; i < l; i++) {
		try{ $Fn(p[i].func).detach(p[i].element, p[i].event) }catch(e){};
	}
}
*/

/*
$Fn.gc.pool = new Array;
if (typeof window != "undefined") {
	$Fn($Fn.gc).attach(window, "unload");
};
*/

function $Json(sObject) {
	var cl = arguments.callee;
	if (typeof sObject == "undefined") sObject = new Object;
	if (sObject instanceof cl) return sObject;
	if (!(this instanceof cl)) return new cl(sObject);

	if (typeof sObject == "string") {
		try {
			sObject = eval("("+sObject+")");
		} catch(e) {
			sObject = new Object;
		}
	}

	this._object = sObject;
}

$Json.fromXML = function(sXML) {
	var o  = new Object;
	var re = /\s*<(\/?[\w:\-]+)((?:\s+[\w:\-]+\s*=\s*"[^"]*")*)\s*>(?:(<\/\1>)|\s*)|\s*<!\[CDATA\[([\w\W]*?)\]\]>\s*|\s*([^<]*)\s*/ig;
	var re2= /^[0-9]+(?:\.[0-9]+)?$/;
	var ec = {"&amp;":"&","&nbsp;":" ","&quot;":"\"","&lt;":"<","&gt;":">"};
	var fg = {tags:["/"],stack:[o]};
	var es = function(s){return s.replace(/&[a-z]+;/g, function(m){ return (typeof ec[m] == "string")?ec[m]:m; })};
	var at = function(s,c){s.replace(/([\w\:\-]+)\s*=\s*"([^"]*)"/g, function($0,$1,$2){ c[$1] = es($2) }) };
	var em = function(o){for(var x in o){if(Object.prototype[x])continue;return false;};return true};
	var cb = function($0,$1,$2,$3,$4,$5) {
		var cur, cdata = "";
		var idx = fg.stack.length - 1;

		if (typeof $1 == "string" && $1) {
			if ($1.substr(0,1) != "/") {
				var has_attr = (typeof $2 == "string" && $2);
				var closed   = (typeof $3 == "string" && $3);
				var newobj   = (!has_attr && closed)?"":{};

				cur = fg.stack[idx];

				if (typeof cur[$1] == "undefined") {
					cur[$1] = newobj;
					cur = fg.stack[idx+1] = cur[$1];
				} else if (cur[$1] instanceof Array) {
					var len = cur[$1].length;
					cur[$1][len] = newobj;
					cur = fg.stack[idx+1] = cur[$1][len];
				} else {
					cur[$1] = [cur[$1], newobj];
					cur = fg.stack[idx+1] = cur[$1][1];
				}

				if (has_attr) at($2,cur);

				fg.tags[idx+1] = $1;

				if (closed) {
					fg.tags.length--;
					fg.stack.length--;
				}
			} else {
				fg.tags.length--;
				fg.stack.length--;
			}
		} else if (typeof $4 == "string" && $4) {
			cdata = $4;
		} else if (typeof $5 == "string" && $5) {
			cdata = es($5);
		}

		if (cdata.length > 0) {
			var par = fg.stack[idx-1];
			var tag = fg.tags[idx];

			if (re2.test(cdata)) cdata = parseFloat(cdata);
			else if (cdata == "true" || cdata == "false") cdata = new Boolean(cdata);

			if (par[tag] instanceof Array) {
				var o = par[tag];
				if (typeof o[o.length-1] == "object" && !em(o[o.length-1])) {
					o[o.length-1].$cdata = cdata;
					o[o.length-1].toString = function(){ return cdata; }
				} else {
					o[o.length-1] = cdata;
				}
			} else {
				if (typeof par[tag] == "object" && !em(par[tag])) {
					par[tag].$cdata = cdata;
					par[tag].toString = function(){ return cdata; }
				} else {
					par[tag] = cdata;
				}
			}
		}
	}

	sXML = sXML.replace(/<(\?|\!-)[^>]*>/g, "");
	sXML.replace(re, cb);

	return $Json(o);
}

$Json.prototype.get = function(sPath) {
	var o = this._object;
	var p = sPath.split("/");
	var re = /^([\w:\-]+)\[([0-9]+)\]$/;
	var stack = [[o]], cur = stack[0];
	var len = p.length, c_len, idx, buf, j, e;

	for(var i=0; i < len; i++) {
		if (p[i] == "." || p[i] == "") continue;
		if (p[i] == "..") {
			stack.length--;
		} else {
			buf = [];
			idx = -1;
			c_len = cur.length;

			if (c_len == 0) return [];
			if (re.test(p[i])) idx = +RegExp.$2;

			for(j=0; j < c_len; j++) {
				e = cur[j][p[i]];
				if (typeof e == "undefined") continue;
				if (e instanceof Array) {
					if (idx > -1) {
						if (idx < e.length) buf[buf.length] = e[idx];
					} else {
						buf = buf.concat(e);
					}
				} else if (idx == -1) {
					buf[buf.length] = e;
				}
			}

			stack[stack.length] = buf;
		}

		cur = stack[stack.length-1];
	}

	return cur;
}

$Json.prototype.toString = function() {
	var func = {
		$ : function($) {
			if (typeof $ == "undefined") return '""';
			if (typeof $ == "boolean") return $?"true":"false";
			if (typeof $ == "string") return this.s($);
			if (typeof $ == "number") return $;
			if ($ instanceof Array) return this.a($);
			if ($ instanceof Object) return this.o($);
		},
		s : function(s) {
			var e = {'"':'\\"',"\\":"\\\\","\n":"\\n","\r":"\\r","\t":"\\t"};
			var c = function(m){ return (typeof e[m] != "undefined")?e[m]:m };
			return '"'+s.replace(/[\\"'\n\r\t]/g, c)+'"';
		},
		a : function(a) {
			var s = "[",c = "",n=a.length;
			for(var i=0; i < n; i++) {
				if (typeof a[i] == "function") continue;
				s += c+this.$(a[i]);
				if (!c) c = ",";
			}
			return s+"]";
		},
		o : function(o) {
			var s = "{",c = "";
			for(var x in o) {
				if (typeof o[x] == "function") continue;
				s += c+this.s(x)+":"+this.$(o[x]);
				if (!c) c = ",";
			}
			return s+"}";
		}
	}

	return func.$(this._object);
}

$Json.prototype.toXML = function() {
	var f = function($,tag) {
		var t = function(s,at) { return "<"+tag+(at||"")+">"+s+"</"+tag+">" };

		switch (typeof $) {
			case "undefined":
			case "null":
				return t("");
			case "number":
				return t($);
			case "string":
				if ($.indexOf("<") < 0) return t($.replace(/&/g,"&amp;"));
				else return t("<![CDATA["+$+"]]>");
			case "boolean":
				return t(String($));
			case "object":
				var ret = "";
				if ($ instanceof Array) {
					var len = $.length;
					for(var i=0; i < len; i++) { ret += f($[i],tag); };
				} else {
					var at = "";

					for(var x in $) {
						if (x == "$cdata" || typeof $[x] == "function") continue;
						ret += f($[x], x);
					}

					if (tag) ret = t(ret, at);
				}
				return ret;
		}
	}

	return f(this._object, "");
};

$Json.prototype.toObject = function() {
	return this._object;
}

$Json.prototype.$value = $Json.prototype.toObject;

function $Date(src) {
	var a=arguments,t="";
	var cl=arguments.callee;

	if (src && src instanceof cl) return src;
	if (!(this instanceof cl)) return new cl(a[0],a[1],a[2],a[3],a[4],a[5],a[6]);

	if ((t=typeof src) == "string") {
		this._date = cl.parse(src).$value();
	} else if (t == "number") {
		if (typeof a[1] == "undefined") this._date = new Date(src);
		else this._date = new Date(a[0],a[1],a[2],a[3],a[4],a[5],a[6]);
	} else if (t && t.constructor == Date) {
		(this._date = new Date).setTime(src.getTime());
		this._date.setMilliseconds(src.getMilliseconds());
	} else {
		this._date = new Date;
	}
}

$Date.names = {
	month   : ["January","Febrary","March","April","May","June","July","August","September","October","Novermber","December"],
	s_month : ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],
	day     : ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],
	s_day   : ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],
	ampm    : ["AM", "PM"]
};

$Date.now = function() {
	return Date.now();
};

$Date.parse = function(strDate) {
	return Date.parse(strDate);
};

$Date.prototype.$value = function(){
	return this._date;
};

$Date.prototype.format = function(strFormat){
	var o = {};
	var d = this._date;

	return (strFormat||"").relace(/[a-z]/ig, function callback(m){
		if (typeof o[m] != "undefined") return o[m];

		switch(m) {
			case"d":
			case"j":
				o.j = d.getDate();
				o.d = (o.j>9?"":"0")+o.j;
				return o[m];
			case"l":
			case"D":
			case"w":
			case"N":
				o.w = d.getDay();
				o.N = o.w?o.w:7;
				o.D = $Date.names.s_day[o.w];
				o.j = $Date.names.day[o.w];
				return o[m];
			case"S":
				return (!!(o.S=["st","nd","rd"][d.getDate()]))?o.S:(o.S="th");
			case"z":
				o.z = Math.floor((d.getTime() - (new Date(d.getFullYear(),0,1)).getTime())/(3600*24*1000));
				return o.z;
			case"m":
			case"n":
				o.n = d.getMonth()+1;
				o.m = (o.n>9?"":"0")+o.n;
				return o[m];
			case"L":
				o.L = this.isLeapYear();
				return o.L;
			case"o":
			case"Y":
			case"y":
				o.o = o.Y = d.getFullYear();
				o.y = (o.o+"").substr(2);
				return o[m];
			case"a":
			case"A":
			case"g":
			case"G":
			case"h":
			case"H":
				o.G = d.getHours();
				o.g = (o.g=o.G%12)?o.g:12;
				o.A = o.G<12?$Date.names.ampm[0]:$Date.names.ampm[1];
				o.a = o.A.toLowerCase();
				o.H = (o.G>9?"":"0")+o.G;
				o.h = (o.g>9?"":"0")+o.g;
				return o[m];
			case"i":
				o.i = (((o.i=d.getMinutes())>9)?"":"0")+o.i;
				return o.i;
			case"s":
				o.s = (((o.s=d.getSeconds())>9)?"":"0")+o.i;
				return o.s;
			case"u":
				o.u = d.getMilliseconds();
				return o.u;
			case"U":
				o.U = this.time();
				return o.U;
			default:
				return m;
		}
	});
};

$Date.prototype.time = function(nTime) {
	if (typeof nTime == "number") {
		this._date.setTime(nTime);
		return this;
	}

	return this._date.getTime();
};

$Date.prototype.year = function(nYear) {
	if (typeof nYear == "number") {
		this._date.setFullYear(nDate);
		return this;
	}

	return this._date.getFullYear();
};

$Date.prototype.month = function(nMon) {
	if (typeof nMon == "number") {
		this._date.setMonth(nDate);
		return this;
	}

	return this._date.getMonth();
};

$Date.prototype.date = function(nDate) {
	if (typeof nDate == "number") {
		this._date.setDate(nDate);
		return this;
	}

	return this._date.getDate();
};

$Date.prototype.day = function() {
	return this._date.getDay();
};

$Date.prototype.hours = function(nHour) {
	if (typeof nHour == "number") {
		this._date.setHours(nHour);
		return this;
	}

	return this._date.getHours();
};

$Date.prototype.minutes = function(nMin) {
	if (typeof nSec == "number") {
		this._date.setSeconds(nMin);
		return this;
	}

	return this._date.getSeconds();
};

$Date.prototype.minutes = function(nSec) {
	if (typeof nMin == "number") {
		this._date.setMinutes(nSec);
		return this;
	}

	return this._date.getMinutes();
};

$Date.prototype.isLeapYear = function() {
	var y = this._date.getFullYear();

	return !(y%4)&&!!(y%100)||!(y%400);
};